<?php $orgAccount = $this->Session->read('org_account'); ?>

<section class='hbox stretch'>
    <section class='scrollable'>
        <ul class="list-group m-none list-group-lg">
            <?php
            if ($members) {

                foreach ($members as $record) {
                    ?>

                    <li class="list-group-item">

                        <a href="#" class="thumb-sm pull-left m-r-sm">
                            <?php if (isset($record['OrganisationMemberImage'][0]['MemberImage']['thumb_url'])) { ?>
                                <img src="<?php echo $this->Html->url($record['OrganisationMemberImage'][0]['MemberImage']['thumb_url']); ?>" class="img-circle">
                            <?php } else { ?>
                                <img src="<?php echo $this->Html->url('/img/admin/no-image.gif'); ?>" class="img-circle">
                            <?php } ?>
                        </a>

                        <a class="profile_link" href="<?php echo $this->Html->url(array('action' => 'member_details', $record['Member']['id'])); ?>" class="clear">
                            <small class="pull-right">
                                <?php
                                $created = $record['Member']['dob'];
                                $dob = date('Y') . date('-m-d', strtotime($created));
                                $day = '';
                                if ($this->Time->isToday($dob)) {
                                    $day = "Today";
                                } else if ($this->Time->isTomorrow($dob)) {
                                    $day = "Tomorrow";
                                } else {
                                    $day = $this->Time->format($dob, "%a, %b %d");
                                }
                                
                                echo $day;
                                ?>
                            </small>
                            <strong class="block"><?php echo $record['Member']['first_name'] . ' ' . $record['Member']['last_name']; ?></strong>
                            <div style='overflow: hidden;'>
                                <small class='pull-left text-muted '>
                                    <?php echo $record['Member']['occupation']; ?>
                                </small>
                                
                                <small class='pull-right text-right'>
                                    <?php 
                                    if( $day == 'Today' && isset($record['Member']['MemberPhoneNumber'][0]) ) {
                                        $number = $record['Member']['MemberPhoneNumber'][0]['number'];
                                        echo "<a href='#' class='text-info send_sms_btn' data-number='{$number}'>"
                                        . "<i class='fa fa-envelope'></i> Send Birthday SMS</a>";
                                    }?>
                                </small>
                            </div>
                            
                        </a>
                    </li>
                    <?php
                }
            } else {
                ?>
                <li class="list-group-item">
                    No Upcoming Birthdays Found
                </li>
            <?php } ?>
        </ul>
    </section>
</section>